import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {Book} from '../../shared/model/book.interface'


@Injectable({
  providedIn: 'root'
})
export class BookApiService{
  constructor(private readonly httpClient: HttpClient) {
  }
  creat(book: Book): Observable<void>{
    return this.httpClient.post<void>('/books',book);
  }

  count(): Observable<any> {
    return this.httpClient.get('/books/count');
  }
  getAll(): Observable<Book[]> {
    return this.httpClient.get<Book[]>('/books');
  }
  delete(bookId: number): Observable<null> {
    return this.httpClient.delete<null>(`/books/${bookId}`);
  }
}
